import { defineStore } from 'pinia'

export const useCounterStore = defineStore('wzData', {
    state: () => ({ token: '',userInfo:'' }),
    actions: {
        doLogin(data) {
           this.$patch(state => {
               state.token = data.data.token
               state.userInfo = data.user
           })
            let wzData = {
                userToken: data.data.token,
                userInfo: data.user
            }
            chrome.storage.local.set({wzData: wzData}, function () {})
        },
        logout(){
            this.$patch(state => {
                state.token = ''
                state.userInfo = ''
            })
            chrome.storage.local.set({wzData: {}}, function () {})
        }
    },
    persist: true,
})
